package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.user.EditorListener;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.data.user.ListProviderCreator;
import com.openbravo.data.user.SaveProvider;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.forms.DataLogicSales;
import com.openbravo.pos.panels.JPanelTable2;
import com.openbravo.pos.ticket.ProductFilter;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

public class ProductsPanel extends JPanelTable2
  implements EditorListener
{
  private ProductsEditor jeditor;
  private ProductFilter jproductfilter;
  private DataLogicSales m_dlSales = null;

  protected void init()
  {
    this.m_dlSales = ((DataLogicSales)this.app.getBean("com.openbravo.pos.forms.DataLogicSales"));
    this.jproductfilter = new ProductFilter();
    this.jproductfilter.init(this.app);
    this.row = this.m_dlSales.getProductsRow();
    this.lpr = new ListProviderCreator(this.m_dlSales.getProductCatQBF(), this.jproductfilter);
    this.spr = new SaveProvider(this.m_dlSales.getProductCatUpdate(), this.m_dlSales.getProductCatInsert(), this.m_dlSales.getProductCatDelete());
    this.jeditor = new ProductsEditor(this.m_dlSales, this.dirty);
  }

  public EditorRecord getEditor()
  {
    return this.jeditor;
  }

  public Component getFilter()
  {
	  //ati
	  if(this.jproductfilter!=null)
    return this.jproductfilter.getComponent();
	return null;
  }

  public Component getToolbarExtras()
  {
    JButton localJButton = new JButton();
    localJButton.setText("ScanPal");
    localJButton.setVisible(this.app.getDeviceScanner() != null);
    localJButton.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        ProductsPanel.this.btnScanPalActionPerformed(paramActionEvent);
      }
    });
    return localJButton;
  }

  private void btnScanPalActionPerformed(ActionEvent paramActionEvent)
  {
    JDlgUploadProducts.showMessage(this, this.app.getDeviceScanner(), this.bd);
  }

  public String getTitle()
  {
    return AppLocal.getIntString("Menu.Products");
  }

  public void activate()
    throws BasicException
  {
	  //ati
	  if(this.jeditor==null)
		  this.jeditor = new ProductsEditor(this.m_dlSales, this.dirty);
	  //ati
	  if( this.jeditor!=null)
	  
    this.jeditor.activate();
	  // 
	  
	  //ati
	  if(this.jproductfilter==null)
	  {
		  this.jproductfilter = new ProductFilter();
		    this.jproductfilter.init(this.app);
	  }
	  if( this.jproductfilter!=null)
    this.jproductfilter.activate();
    super.activate();
  }

  public void updateValue(Object paramObject)
  {
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.ProductsPanel
 * JD-Core Version:    0.6.0
 */